package web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.NoticeDao;
import dao.NoticeDaoFactory;
import entity.Notice;

/*
 * 作用：更新之前，显示原来的数据，提供给户参考
 */

@WebServlet("/UpdateNoticeViewServlet")
public class UpdateNoticeViewServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//1.获取id
		String id = request.getParameter("id");
		//2.通过service(dao)取得数据
		NoticeDao dao = new NoticeDaoFactory().factory();
		Notice notice = dao.queryById(id);
		
		//3.跳转到编辑页面，显示数据
		request.setAttribute("notice", notice);
		request.getRequestDispatcher("edit.jsp").forward(request, response);
	
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
